import { Company } from "src/modules/company/company.entity";
import { Delivery } from "src/modules/delivery/delivery.entity";
import { Order } from "src/modules/order/order.entity";
import {
  Column,
  CreateDateColumn,
  Entity,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from "typeorm";

@Entity()
export class Client {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @CreateDateColumn()
  date: Date;

  @Column()
  name: string;

  @Column({ default: "" })
  short: string;

  @Column({ default: "" })
  address: string;

  @Column({ default: "" })
  contact: string;

  @Column({ default: 1 })
  summary: number;

  @ManyToOne(() => Company, (company) => company.clients, { nullable: false })
  company: Company;

  @OneToMany(() => Order, (order) => order.client)
  orders: Order[];

  @OneToMany(() => Delivery, (delivery) => delivery.client)
  deliveries: Delivery[];
}
